<?php include_once("common.php");
class Item extends BaseEntity implements BaseOperations
{
	private $item;
	private $categoryId;
	private $count;
	private $dimension;
	private $price;
	private $arrival;
	
	// PROPERTIES
	public function getLabel()
	{
		return $this->item;
	}
	
	public function setLabel($item)
	{
		$this->item = $item;
	}
	
	public function getCategory()
	{
		return $this->categoryId;
	}
	
	public function setCategory($id)
	{
		$this->categoryId=$id;
	}
	
	public function getCount()
	{
		return $this->count;
	}
	
	public function setCount($count)
	{
		$this->count = $count;
	}
	
	public function getDimension()
	{
		return $this->dimension;
	}
	
	public function setDimension($count)
	{
		$this->dimension = $count;
	}
	
	public function getPrice()
	{
		return $this->price;
	}
	
	public function setPrice($price)
	{
		$this->price = $price;
	}
	
	public function getArrival()
	{
		return $this->arrival;
	}
	
	public function setArrival($date)
	{
		$this->arrival = $date;
	}
	
	// METHODS
	public function GetRecordById($id)
	{
		$res = mysql_query("SELECT * FROM items WHERE id = ".$id);
		
		$f = mysql_fetch_array($res);
				
		$tmp = new Item;
		$tmp->setId($f[id]);
		$tmp->setLabel($f[label]);
		$tmp->setCategory($f[categoryId]);
		$tmp->setCount($f[count]);
		$tmp->setDimension($f[dimension]);
		$tmp->setPrice($f[price]);
		$tmp->setArrival($f[arrival]);
		
		return $tmp;
	}
	
	public function GetAllRecords()
	{
		$result = array();
			
		$res = mysql_query("SELECT * FROM items;");
		
		for ($c=0; $c<mysql_num_rows($res); $c++)
		{
			$f = mysql_fetch_array($res);
			
			$tmp = new Item;
			$tmp->setId($f[id]);
			$tmp->setLabel($f[label]);
			$tmp->setCategory($f[categoryId]);
			$tmp->setCount($f[count]);
			$tmp->setDimension($f[dimension]);
			$tmp->setPrice($f[price]);
			$tmp->setArrival($f[arrival]);
			
			$result[] = $tmp;
		}
		
		return $result;
	}

	public function AddNewRecord()
	{
		// should be implemented
	}
	
	public function UpdateRecord()
	{
		// should be implemented
	}
	
	public function RemoveRecordById($id)
	{
		// should be implemented
	}
}
?>